/*
 * Copyright (c) 2018. Jahir Fiquitiva
 *
 * Licensed under the CreativeCommons Attribution-ShareAlike
 * 4.0 International License. You may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 *
 *    http://creativecommons.org/licenses/by-sa/4.0/legalcode
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package jahirfiquitiva.libs.blueprint.ui.fragments.dialogs

import android.support.v4.app.DialogFragment
import android.support.v4.app.FragmentActivity

abstract class BasicDialogFragment : DialogFragment() {
    fun dismiss(activity: FragmentActivity, tag: String) {
        try {
            val frag = activity.supportFragmentManager.findFragmentByTag(tag)
            if (frag != null) (frag as IconDialog).dismiss()
        } catch (ignored: Exception) {
        }
        try {
            dismiss()
        } catch (ignored: Exception) {
        }
    }
}